/*--------------------------------------------------------------------------------
 * Adaptive Intelligence - Windows Forms Controls Class Library
 * Version 2.00
 * 
 * Advanced Splitter Class
 *      Extends the  Windows Forms Splitter Control which draws itself with
 * raised borders for easier viewing by the user.
 *------------------------------------------------------------------------------*/

/*--------------------------------------------------------------------------------
 * System Imports
 *------------------------------------------------------------------------------*/
using System;
using System.Text;
using System.ComponentModel;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Windows.Forms;

namespace Adaptive.Foundation.Windows.Forms
{
    /// <summary>
    /// Extends the Windows Forms Splitter Control which draws itself with
    /// raised borders for easier viewing by the user.w
    /// </summary>
    [Browsable(true), ToolboxItem(true), DesignerCategory("Splitter"),
   ToolboxBitmap(typeof(EmbeddedResourceFinder), "Adaptive.Foundation.Windows.Forms.AdvancedSplitter.bmp")]
    public partial class AdvancedSplitter : Splitter
    {
        /*--------------------------------------------------------------------------------
         * Constructor / Dispose / Destructor Methods
         *------------------------------------------------------------------------------*/
        #region Constructor / Dispose / Destructor Methods
        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        /// <remarks>
        /// This is the default constructor.
        /// </remarks>
        public AdvancedSplitter()
            : base()
        {
            InitializeComponent();
        }
        /// <summary>
        /// Deallocates internally allocated objects.
        /// </summary>
        /// <param name="disposing">
        /// A value indicating whether the object is being disposed.
        /// </param>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (components != null)
                    components.Dispose();
            }
            components = null;
            base.Dispose(disposing);
        }
        #endregion

        /*--------------------------------------------------------------------------------
         * Protected Methods / Event Methods
         *------------------------------------------------------------------------------*/
        #region Protected Methods / Event Methods
        /// <summary>
        /// Paints the background of the control.
        /// </summary>
        /// <remarks>
        /// Draws the background of the splitter control as a gradient color transition
        /// from white to the current system control color.
        /// </remarks>
        /// <param name="e"></param>
        protected override void OnPaintBackground(PaintEventArgs e)
        {
            LinearGradientBrush brush = null;		//Brush for drawing.

            //Raise the base event.
            base.OnPaintBackground(e);

            //Create the brush to draw a rectangle the size of the control, 
            //filled with a color transition from white to the system control color,
            //drawing the transition in a forward-leaning diagonal style.
            brush = new LinearGradientBrush(new Rectangle(0, 0, Width, Height),
                Color.White, SystemColors.Control,
                LinearGradientMode.ForwardDiagonal);
            e.Graphics.FillRectangle(brush, new Rectangle(0, 0, Width, Height));

            //Clear memory.
            brush.Dispose();
            brush = null;

        }
        /// <summary>
        /// Paints the border image.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPaint(PaintEventArgs e)
        {
            //Draw the left "raised" line.
            e.Graphics.DrawLine(SystemPens.ControlLightLight, 0, Height, 0, 0);
            //Draw the top "Raised" line.
            e.Graphics.DrawLine(SystemPens.ControlLightLight, 0, 0, Width, 0);
            //Draw the right "inset" line.
            e.Graphics.DrawLine(SystemPens.ControlDark, Width - 1, 1, Width - 1, Height);
            //Draw the bottom "inset" line.
            e.Graphics.DrawLine(SystemPens.ControlDark, 0, Height - 1, Width, Height - 1);
        }
        #endregion
    }
}